import { createRouter, createWebHistory, createWebHashHistory } from 'vue-router';

const routes = [
	{
		path: '/',
		redirect: '/PlaceOrder'
	},
	{
		path: '/PlaceOrder',
		name: 'PlaceOrder',
		component: () => import('@/views/PlaceOrder/index.vue'),
		meta: { title: '下单' }
	},
	{
		path: '/HabitBandDoctor',
		name: 'HabitBandDoctor',
		component: () => import('@/views/HabitBandDoctor/index.vue'),
		meta: { title: '习惯绑定医生' }
	},
	{
		path: '/HabitBandHospital',
		name: 'HabitBandHospital',
		component: () => import('@/views/HabitBandHospital/index.vue'),
		meta: { title: '习惯绑医院' }
	},
	{
		path: '/HabitBandProduct',
		name: 'HabitBandProduct',
		component: () => import('@/views/HabitBandProduct/index.vue'),
		meta: { title: '习惯绑定产品' }
	},
	{
		path: '/HabitBandProcesses',
		name: 'HabitBandProcesses',
		component: () => import('@/views/HabitBandProcesses/index.vue'),
		meta: { title: '习惯绑定产品工序' }
	},
	{
		path: '/ProductBandProductProcess',
		name: 'ProductBandProductProcess',
		component: () => import('@/views/ProductBandProductProcess/index.vue'),
		meta: { title: '产品绑定产品工序' }
	},
	{
		path: '/EmployeeBindingProcess',
		name: 'EmployeeBindingProcess',
		component: () => import('@/views/EmployeeBindingProcess/index.vue'),
		meta: { title: '员工绑定产品工序' }
	},
	{
		path: '/PersonnelBindingItems',
		name: 'PersonnelBindingItems',
		component: () => import('@/views/PersonnelBindingItems/index.vue'),
		meta: { title: '人员绑定物品' }
	},
	{
		path: '/MachiningCenter',
		name: 'MachiningCenter',
		component: () => import('@/views/MachiningCenter/index.vue'),
		meta: { title: '加工中心' }
	},
	{
		path: '/Test',
		name: 'Test',
		component: () => import('@/views/Test/index.vue'),
		meta: { title: '测试' }
	}
];
const router = createRouter({
	routes,
	history: createWebHashHistory(),
	scrollBehavior: () => {
		return { top: 0 };
	}
});

router.beforeEach((to, from, next) => {
	document.title = to.meta.title || '和和工艺';
	next();
});

export default router;
